package com.test.spring2025_4_3.Demo;

import java.util.*;
import java.util.stream.Collectors;

public class code1 {
    public static void main(String[] args) {
//        HashMap<String, Integer> map = new HashMap<>();
//        Integer i = map.computeIfAbsent("John", key -> 100);
//
//        People people1 = new People();

        List<People> people = Arrays.asList(
                new People("Alice",20),
                new People("Bob", 25),
                new People("Charlie", 30),
                new People("David", 25)
        );

        Map<Integer, List<People>> collect = people.stream().collect(Collectors.groupingBy(p -> p.getAge()));
        System.out.println(collect);
    }
}
